﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/admin.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="admin_Category_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script type="text/javascript">
        jQuery(document).ready(function () {
            jQuery(".form").colorbox({ width: "500px", inline: true, href: "#frmAddNew" });
        });
        function closeOverlay() {
            $.colorbox.close();
        }
        function insertUrl(url) {
            $("[id$='txtUrl']").val(url);
            closeOverlay();
        }

        //ShowStatus('warning', 'Thêm mới chuyên mục thất bại.');
    </script>
    <div style="display: none;">
        <div id="frmAddNew" class="overlaypanel">
            <h2>Thêm menu</h2>
            <ul class="fl">
                <li>
                    <label>Menu</label>
                    <br />
                    <asp:TextBox runat="Server" ID="txtName" Width="200" />
                    <asp:CustomValidator runat="Server" ID="valExist" ValidationGroup="new" ControlToValidate="txtName"
                        ErrorMessage="Menu đã tồn tại" Display="dynamic" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="Server" ValidationGroup="new"
                        ControlToValidate="txtName" ErrorMessage="Nhập tên Menu" Display="Dynamic" />
                </li>
                <li>
                    <label>Menu Group</label><br />
                    <asp:DropDownList runat="Server" ID="ddlMenuGroup" Width="200" AppendDataBoundItems="true">
                        <asp:ListItem Value="2">none</asp:ListItem>
                    </asp:DropDownList>
                </li>
                <li>
                    <label>Url</label><br />
                    <asp:TextBox runat="Server" ID="txtUrl" Width="400" />
                </li>
                <li>
                    <label>Icon</label><br />
                    <asp:TextBox runat="Server" ID="txtIconUrl" Width="400" />
                </li>
                <li>
                    <label>Sắp xếp</label><br />
                    <asp:TextBox runat="Server" ID="txtSortIndex" Width="200" />
                </li>
                <li>Menu con của:<br />
                    <asp:DropDownList ID="ddlMenuParent" Width="200" runat="server" AppendDataBoundItems="true">
                        <asp:ListItem Value="0">none</asp:ListItem>
                    </asp:DropDownList>
                    &nbsp;&nbsp;&nbsp;&nbsp; Cho phép hiển thị:
                            <asp:CheckBox ID="chkIsActive" runat="server" />
                </li>
            </ul>
            <asp:Button runat="server" ID="btnAdd" ValidationGroup="new" CssClass="btn primary"
                OnClientClick="colorboxDialogSubmitClicked('form', 'frmAddNew');"
                Text="Thêm mới" OnClick="btnAdd_Click" />
            hoặc <a href="#" onclick="closeOverlay();">Hủy</a>
        </div>
    </div>
    <div class="content-box-outer">
        <div class="content-box-right">
            <ul>
                <li><a href="Add_Edit.aspx" class="new tooltip" title="Thêm nhanh">Thêm danh mục</a></li>
                <li class="content-box-selected"><a href="Default.aspx">Danh mục</a></li>
              
            </ul>
        </div>
        <div class="content-box-left">
            <h1>Danh mục <a href="Add_Edit.aspx" class="addNew">Thêm danh mục

                 
                         </a>
                 <a href="#" class="timkiem">Tìm kiếm
                                   </a>

            </h1>
            <%if (Count() == 0)
              { %>
            <div class="info">
                Bạn chưa có danh mục. <a href="Add_Edit.aspx">Thêm bài viết mới</a>
            </div>
            <%}
              else
              { %>
            <div id="Container">
                <div id="timkiem" style="display: none;">
             
              <script type="text/javascript">

                  $(document).ready(function () {

                      $(".timkiem").click(function () {
                          $("#timkiem").toggle("slow");
                      });

                  });

                  function doSearch() {
                      // var filter = document.timkiem.search.options[document.timkiem.search.selectedIndex].value;
                      var tukhoa = document.getElementById("txtTimKiem").value;
                      if (tukhoa.length == 0) {
                          alert('Nhập từ khóa cần tìm...');
                          return false;
                      }
                      else {
                          var url = "Default.aspx?q=" + tukhoa;
                          window.location = url;
                          return true;
                      }
                  }
              </script>
                 <h2>  Tìm kiếm</h2>
                    <table class="tblForm">
                        <tr>
                        
                            <td>  
                                <label for="txtTimKiem" class="lbl">Nhập từ khóa tìm kiếm</label>
                                <input type="text" name="txtTimKiem" id="txtTimKiem" class="txt200"/> 
                                <input type="button" class="btn primary rounded" value="Tìm kiếm" name="addFile" onclick="return doSearch()" />                               
                            </td>                                                      
                        </tr>                         
                    </table>
              
                
                        </div>
                <div class="tableToolBox">
                    Hiển thị: <a class="current" href="Default.aspx" title="Tất cả">Tất cả </a>
                    | <a href="Default.aspx?IsPublished=False" title="Nháp">Nháp</a> | <a
                        href="Default.aspx?IsPublished=True" title="Kích hoạt">Đã kích hoạt</a>
                    <span id="filteredby">Có tất cả <%=Count() %> bản tin được tìm thấy</span>
                    <div class="Pager">
                        <asp:PagingControl ID="PagingControl1" runat="server" PageSize="1" FirstPageText=""
                            LastPageText="" PreviousPageText="" NextPageText="" />
                    </div>
                    <div class="PageSize">
                        <label for="pageSizeTop">
                            Số dòng / trang
                        </label>
                        <select id="pageSizeTop" name="pageSizeTop" onchange="return ChangePageSize(this)">
                            <option value="10" selected="selected">10</option>
                            <option value="25">25</option>
                            <option value="50">50</option>
                            <option value="100">100</option>
                        </select>
                    </div>
                </div>
                <table id="Posts" class="beTable rounded" style="width: 100%">
                    <thead>
                        <tr>
                            <th width="100" style="text-align: center;">Kích hoạt
                            </th>
                             <th width="100">Hình ảnh
                            </th>
                            <th width="auto">Tên danh mục
                            </th>
                           
                            <th width="auto">Nhóm
                            </th>
                            
                            <th width="120">Sắp xếp
                            </th>
                            <th width="120"></th>
                        </tr>
                    </thead>
                    <tbody>
                        <asp:Repeater ID="rpt" runat="server">
                            <ItemTemplate>
                                <tr id="{$T.p.Id}" class="simplehighlight">
                                    <td style="text-align: center;">
                                        <span class="published-<%#Eval("IsActive").ToString().ToLower() %> tooltip" title=" <%#Eval("IsActive").ToString().ToLower()=="false"?"Duyệt":"Chờ duyệt" %>" onclick="return $.dalatcooking.jsonCategorySetActive(<%#Eval("CategoryID") %>);"></span>
                                    </td>
                                    <td>
                                        <span><img src="ThumbnailHandler.axd?img=<%#Eval("Picture") %>" /></span>
                                    </td>
                                    <td>
                                        <span>
                                            <b><%#Eval("Name") %></b></span>
                                    </td>
                                     
                                    <td>
                                        <span>
                                            <span>
                                    </td>
                                   
                                    <td>
                                        <span>
                                            <%#Eval("SortIndex") %></span>

                                        <span class="sortdown tooltip" title="Sắp xếp giảm" onclick="return $.dalatcooking.jsonCategorySetSortIndex(<%#Eval("CategoryID") %>, -1);"></span>
                                        <span class="sortup tooltip" title="Sắp xếp tăng" onclick="return $.dalatcooking.jsonCategorySetSortIndex(<%#Eval("CategoryID") %>, 1);"></span>
                                    </td>
                                    </td>
                                    <td>
                                        <ul class="rowTools">
                                            <li><a class="toolsAction" href="#"><span class="">Công cụ</span></a>
                                                <ul class="rowToolsMenu">
                                                    <li><a class="editAction" href="Add_Edit.aspx?CategoryID=<%#Eval("CategoryID") %>">Sửa</a></li>

                                                    <li><a class="published-<%#Eval("IsActive").ToString().ToLower()=="false"?"true":"false" %>" href="#" onclick="return $.dalatcooking.jsonCategorySetActive(<%#Eval("CategoryID") %>);">
                                                        <%#Eval("IsActive").ToString().ToLower()=="false"?"Duyệt":"Chờ duyệt" %>
                                                    </a></li>

                                                    <li><a class="deleteAction" href="#" onclick="return $.dalatcooking.jsonCategoryDelete(<%#Eval("CategoryID") %>);">Xóa</a></li>
                                                </ul>
                                            </li>
                                        </ul>
                                    </td>
                                </tr>

                                <asp:Repeater ID="rptChild" runat="server" DataSource='<%#CategoryByParent(Eval("CategoryID")) %>'>
                            <ItemTemplate>
                                <tr id="{$T.p.Id}" class="simplehighlight">
                                    <td style="text-align: center;">
                                        <span class="published-<%#Eval("IsActive").ToString().ToLower() %> tooltip" title=" <%#Eval("IsActive").ToString().ToLower()=="false"?"Duyệt":"Chờ duyệt" %>" onclick="return $.dalatcooking.jsonCategorySetActive(<%#Eval("CategoryID") %>);"></span>
                                    </td>
                                    <td>
                                        <span><img src="ThumbnailHandler.axd?img=<%#Eval("Picture") %>" /></span>
                                    </td>
                                    <td>
                                        <span>
                                            <b>&nbsp;&nbsp;&nbsp;&nbsp;|__&nbsp;<%#Eval("Name") %></b></span>
                                    </td>
                                     
                                    <td>
                                        <span>
                                            <span>
                                    </td>
                                   
                                    <td>
                                        <span>
                                            <%#Eval("SortIndex") %></span>

                                        <span class="sortdown tooltip" title="Sắp xếp giảm" onclick="return $.dalatcooking.jsonCategorySetSortIndex(<%#Eval("CategoryID") %>, -1);"></span>
                                        <span class="sortup tooltip" title="Sắp xếp tăng" onclick="return $.dalatcooking.jsonCategorySetSortIndex(<%#Eval("CategoryID") %>, 1);"></span>
                                    </td>
                                    </td>
                                    <td>
                                        <ul class="rowTools">
                                            <li><a class="toolsAction" href="#"><span class="">Công cụ</span></a>
                                                <ul class="rowToolsMenu">
                                                    <li><a class="editAction" href="Add_Edit.aspx?CategoryID=<%#Eval("CategoryID") %>">Sửa</a></li>

                                                    <li><a class="published-<%#Eval("IsActive").ToString().ToLower()=="false"?"true":"false" %>" href="#" onclick="return $.dalatcooking.jsonCategorySetActive(<%#Eval("CategoryID") %>);">
                                                        <%#Eval("IsActive").ToString().ToLower()=="false"?"Duyệt":"Chờ duyệt" %>
                                                    </a></li>

                                                    <li><a class="deleteAction" href="#" onclick="return $.dalatcooking.jsonCategoryDelete(<%#Eval("CategoryID") %>);">Xóa</a></li>
                                                </ul>
                                            </li>
                                        </ul>
                                    </td>
                                </tr>

                                
                            </ItemTemplate>
                        </asp:Repeater>
                            </ItemTemplate>
                        </asp:Repeater>
                    </tbody>
                </table>
                <div class="Pager">
                    <asp:PagingControl ID="PagingControl2" runat="server" PageSize="1" FirstPageText=""
                        LastPageText="" PreviousPageText="" NextPageText="" />
                </div>
                <div class="PageSize">
                    <label for="pageSizeBottom">
                        Bản tin/Trang</label>
                    <select id="pageSizeBottom" name="pageSizeBottom" onchange="return ChangePageSize(this)">
                        <option value="10">10</option>
                        <option value="25" selected="selected">25</option>
                        <option value="50">50</option>
                        <option value="100">100</option>
                    </select>
                </div>
            </div>
            <%} %>
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $('tr:odd').addClass('alt');
            $('tr:even').removeClass('alt');
            //LoadPostsForPage(1);
            $(".tableToolBox a").click(function () {
                $(".tableToolBox a").removeClass("current");
                $(this).addClass("current");
            });
        });
    </script>
</asp:Content>





